{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3e76772",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu1801\":\"ZiQi\",\n",
    "    \"stu1802\":\"XiaoFeng\",\n",
    "    \"stu1803\":\"LiuYu\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3cf5e777",
   "metadata": {},
   "outputs": [],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b20456d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 循环遍历一个字典\n",
    "# i是 item 在字典中打印的是什么？\n",
    "# 我想遍历整个\n",
    "for i in info:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c941b417",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践1：将其中的key取出数字作为新的字典 stu1801 中取出数字，新的字典key\n",
    "new_info = {}\n",
    "for k,v in info.items():\n",
    "    # 用字典新增的方式创建字典\n",
    "    new_info[k[3:]] = v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b4637ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4c61f68",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践2： value 我也想变，所有字母大写\n",
    "new_info = {}\n",
    "for k,v in info.items():\n",
    "    # 用字典新增的方式创建字典\n",
    "    new_info[k[3:]] = v.upper()\n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "720dc905",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_info # 结果是字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "874fdffd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践3：让new_info key 由 ‘1801’=> 1801\n",
    "new_info = {}\n",
    "for k,v in info.items():\n",
    "    # 用字典新增的方式创建字典\n",
    "    new_info[int(k[3:])] = v.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37c8b665",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
